package com.anxin.act.busFlow.web;

import java.util.List;

import com.anxin.common.constant.UserConstants;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.anxin.framework.aspectj.lang.annotation.Log;
import com.anxin.framework.aspectj.lang.enums.BusinessType;
import com.anxin.act.busFlow.entity.WfConfigFlow;
import com.anxin.act.busFlow.service.WfConfigFlowService;
import com.anxin.framework.web.controller.BaseController;
import com.anxin.framework.web.entity.AjaxResult;
import com.anxin.common.utils.poi.ExcelUtil;
import com.anxin.framework.web.page.TableDataInfo;

/**
 * 业务流程配置Controller
 *
 * @author jbs
 * @date 2020-04-08
 */
//@Api(tags = "业务流程配置" )
@RestController
@RequestMapping("/flow/wfConfigFlow")
public class WfConfigFlowController extends BaseController{
    @Autowired
    private WfConfigFlowService wfConfigFlowService;

    /**
     * 查询业务流程配置列表
     */
    //@ApiOperation(value="查询业务流程配置列表" ,notes="作者:jbs")
    @PreAuthorize("@ss.hasPermi('act:busflow:view')")
    @GetMapping("/list")
    @Log(title = "查询业务流程配置列表", businessType = BusinessType.LIST)
    public TableDataInfo<List<WfConfigFlow>> list(WfConfigFlow wfConfigFlow){
        startPage();
        List<WfConfigFlow> list = wfConfigFlowService.findList(wfConfigFlow);
        return getDataTable(list);
    }

    /**
     * 导出业务流程配置列表
     */
    //@ApiOperation(value="导出业务流程配置列表",notes="作者:jbs")
    @PreAuthorize("@ss.hasPermi('act:busflow:export')")
    @Log(title = "业务流程配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WfConfigFlow wfConfigFlow) {
        List<WfConfigFlow> list = wfConfigFlowService.findList(wfConfigFlow);
        ExcelUtil<WfConfigFlow> util = new ExcelUtil<WfConfigFlow>(WfConfigFlow.class);
        return util.exportExcel(list, "flow");
    }

    /**
     * 获取业务流程配置详细信息
     */
    //@ApiOperation(value="获取业务流程配置详细信息",notes="作者:jbs")
    @PreAuthorize("@ss.hasPermi('act:busflow:view')")
    @GetMapping(value = "/{id}")
    @Log(title = "获取业务流程配置详细信息", businessType = BusinessType.LIST)
    public AjaxResult<WfConfigFlow> getInfo(@PathVariable("id") String id){
        return AjaxResult.success(wfConfigFlowService.getById(id));
    }

    /**
     * 保存业务流程配置
     */
    //@ApiOperation(value="保存业务流程配置",notes="作者:jbs")
    @PreAuthorize("@ss.hasPermi('act:busflow:edit')")
    @Log(title = "业务流程配置", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    public AjaxResult save(@RequestBody WfConfigFlow wfConfigFlow){
        if (!wfConfigFlowService.checkWfConfigFlow(wfConfigFlow)) {
            return AjaxResult.error("该配置项已存在，请检查后配置");
        }
        return toAjax(wfConfigFlowService.save(wfConfigFlow));
    }


    /**
     * 删除业务流程配置
     */
    //@ApiOperation(value="删除业务流程配置",notes="作者:jbs")
    @PreAuthorize("@ss.hasPermi('act:busflow:remove')")
    @Log(title = "业务流程配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable(("id")) String id){
        return toAjax(wfConfigFlowService.deleteById(id));
    }
}
